package com.ruoyi.civil.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.civil.domain.CivilEnginneeringSpecialInspection;
import com.ruoyi.civil.service.ICivilEnginneeringSpecialInspectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专项检查Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/civil/specialinspection")
public class CivilEnginneeringSpecialInspectionController extends BaseController
{
    @Autowired
    private ICivilEnginneeringSpecialInspectionService civilEnginneeringSpecialInspectionService;

    /**
     * 查询专项检查列表
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(CivilEnginneeringSpecialInspection civilEnginneeringSpecialInspection)
    {
        startPage();
        List<CivilEnginneeringSpecialInspection> list = civilEnginneeringSpecialInspectionService.selectCivilEnginneeringSpecialInspectionList(civilEnginneeringSpecialInspection);
        return getDataTable(list);
    }

    /**
     * 导出专项检查列表
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:export')")
    @Log(title = "专项检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CivilEnginneeringSpecialInspection civilEnginneeringSpecialInspection)
    {
        List<CivilEnginneeringSpecialInspection> list = civilEnginneeringSpecialInspectionService.selectCivilEnginneeringSpecialInspectionList(civilEnginneeringSpecialInspection);
        ExcelUtil<CivilEnginneeringSpecialInspection> util = new ExcelUtil<CivilEnginneeringSpecialInspection>(CivilEnginneeringSpecialInspection.class);
        util.exportExcel(response, list, "专项检查数据");
    }

    /**
     * 获取专项检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:query')")
    @GetMapping(value = "/{specialInspectionId}")
    public AjaxResult getInfo(@PathVariable("specialInspectionId") Long specialInspectionId)
    {
        return AjaxResult.success(civilEnginneeringSpecialInspectionService.selectCivilEnginneeringSpecialInspectionBySpecialInspectionId(specialInspectionId));
    }

    /**
     * 新增专项检查
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:add')")
    @Log(title = "专项检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CivilEnginneeringSpecialInspection civilEnginneeringSpecialInspection)
    {
        return toAjax(civilEnginneeringSpecialInspectionService.insertCivilEnginneeringSpecialInspection(civilEnginneeringSpecialInspection));
    }

    /**
     * 修改专项检查
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:edit')")
    @Log(title = "专项检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CivilEnginneeringSpecialInspection civilEnginneeringSpecialInspection)
    {
        return toAjax(civilEnginneeringSpecialInspectionService.updateCivilEnginneeringSpecialInspection(civilEnginneeringSpecialInspection));
    }

    /**
     * 删除专项检查
     */
    @PreAuthorize("@ss.hasPermi('civil:specialinspection:remove')")
    @Log(title = "专项检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{specialInspectionIds}")
    public AjaxResult remove(@PathVariable Long[] specialInspectionIds)
    {
        return toAjax(civilEnginneeringSpecialInspectionService.deleteCivilEnginneeringSpecialInspectionBySpecialInspectionIds(specialInspectionIds));
    }
}
